<script>
import { getUserInfo } from 'vue-xiaobu-utils'
import { detectionGoToPage } from '@/utils/JumpUtils'
export default {
  data() {
    return {
      name: '立即登录',
      phone: '必不可少的生活方式',
      headPortrait: require('../assets/touxiang.png')
    }
  },
  methods: {
    // 获取登录后的用户信息用来显示
    getUserDetails() {
      let userPhone = getUserInfo().PHONE
      let headIcon = getUserInfo().ICON
      if (this.isLogin === 1) {
        this.name = getUserInfo().NICK_NAME
        this.phone = userPhone.substring(0, 3) + '****' + userPhone.substr(userPhone.length - 4)
        if (headIcon !== '') {
          this.headPortrait = getUserInfo().ICON
        }
      } else {
        this.name = '立即登录'
        this.phone = '必不可少的生活方式'
        this.headPortrait = require('../assets/touxiang.png')
      }
    },
    // 点击登录模块进行跳转
    jumpLogin() {
      detectionGoToPage('city-app/personalinfo.html?_tv=true&_rv=false&_abs=true&_bbv=true&_im=true')
    }
  },
  watch: {
    isLogin() {
      this.getUserDetails()
    },
    resumeCount() {
      this.getUserDetails()
    }
  },
  computed: {
    isLogin() {
      return this.$store.getters.loginStatus
    },
    resumeCount() {
      return this.$store.getters.resumeCount
    }
  }
}
</script>
